package two_shang.otherTest.ThreadPackage;

public class TestDaemon {
    public static void main(String[] args) {
        God god = new God();
        You you = new You();

        Thread God = new Thread(god);
        Thread You = new Thread(you);

        God.setDaemon(true);

        God.start();
        You.start();
    }

}


//上帝

class God implements Runnable {

    @Override
    public void run() {
        while (true) {
            System.out.println("上帝守护你~");
        }
    }
}

//你
class You implements Runnable {

    @Override
    public void run() {
        for (int i = 0; i < 1000; i++) {
            System.out.println("你活着.");
        }
        System.out.println("虚拟机不会立即关闭");

    }
}
